package gengine.common.misc;

import java.io.Serializable;
import java.util.Date;

/**
 * User: Arseniy
 * Date: 21.12.11
 * Time: 9:05
 */
public class ClientInfo implements Serializable {
    String name;
    String ipAddress;
    Date connectedAt;
    private int id;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getIpAddress() {
        return ipAddress;
    }

    public void setIpAddress(String ipAddress) {
        this.ipAddress = ipAddress;
    }

    public Date getConnectedAt() {
        return connectedAt;
    }

    public void setConnectedAt(Date connectedAt) {
        this.connectedAt = connectedAt;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public void Apply(ClientInfo info) throws InconsistentInfoException {
        if (id!=info.id) {
            throw new InconsistentInfoException("ids r not equal");
        }
        if (ipAddress.compareTo(info.ipAddress)!=0)
            throw new InconsistentInfoException("ips r not equal");

        connectedAt = info.connectedAt;
        name = info.name;
    }
}
